import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/pages/index/Index'
import Error404 from '@/pages/error/Error404'
import user from './user'
import info from './info'
import article from './article'
import live from './live'
import video from "./video"
import register from './register'
import login from './login'
import Auth from '@/pages/login/Auth'
import search from "./search"
import publicSurvey from "./publicSurvey"

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.VIRTUAL_BASE,
  routes: [
    {
      path: '/',
      redirect: { path: '/index' }
    },
    // 404
    {
      path: '*',
      name: 'Error404',
      component: Error404,
      meta: {
        title: '404'
      }
    },
    // 首页
    {
      path: '/index',
      name: 'Index',
      component: Index,
      meta: {
        title: '首页'
      }
    },
    {
      path: '/auth',
      name: 'Auth',
      component: Auth,
      meta: {
        title: '跳转中...'
      }
    },
    ...user, // 我的
    ...article, // 病例解读
    ...info, // 病例解读
    ...live, // 直播
    ...video,//图谱课程
    ...register, // 注册
    ...login,// 登陆
    ...search,//搜素
    ...publicSurvey,//众测
  ],
  // 路由跳转是定位在页面顶部
  scrollBehavior (to, from, savedPosition) {
    return {
      x: 0,
      y: 0
    }
  }
})
